package com.qianli.user.facade.impl.behavior;

import com.fqgj.common.api.Response;
import com.qianli.user.application.UserBehaviorApplication;
import com.qianli.user.facade.behavior.UserBehaviorServiceFacade;
import com.qianli.user.ro.UserStateCode;
import com.qianli.user.ro.behavior.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * name:行为服务
 * auth:ting.li@qianli-inc.com
 * date:2018/1/3 09:45
 * version: v1.0.0
 **/
@Service("userBehaviorServiceFacade")
public class UserBehaviorServiceFacadeImpl implements UserBehaviorServiceFacade{

    private static final Logger LOGGER = LoggerFactory.getLogger(UserBehaviorServiceFacade.class);
    @Autowired
    private UserBehaviorApplication userBehaviorApplication;
    /**
     * 保存行为信息
     * @param userBehaviorInfo
     * @return
     */
    @Override
    public Response<Boolean> saveUserBehaviorInfo(UserBehaviorInfoRO userBehaviorInfo) {
        if(null == userBehaviorInfo){
            LOGGER.info("UserBehaviorServiceFacade.saveUserBehaviorInfo param can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK,"参数不能为空");
        }
        if(null == userBehaviorInfo.getUserCode()){
            LOGGER.info("UserBehaviorServiceFacade.saveUserBehaviorInfo param userCode can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK,"参数不能为空");
        }
        Response<Boolean> response = userBehaviorApplication.saveUserBehaviorInfo(userBehaviorInfo);
        return response;
    }

    /**
     * 保存行为信息-- 设备
     * @param userBehaviorDevice
     * @return
     */
    @Override
    public Response<Boolean> saveUserBehaviorDevice(UserBehaviorDeviceRO userBehaviorDevice) {
        if(null == userBehaviorDevice){
            LOGGER.info("UserBehaviorServiceFacade.saveUserBehaviorDevice param can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK,"参数不能为空");
        }
        if(null == userBehaviorDevice.getUserCode()){
            LOGGER.info("UserBehaviorServiceFacade.saveUserBehaviorDevice param userCode can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK,"参数不能为空");
        }
        Response<Boolean> response = userBehaviorApplication.saveUserBehaviorDevice(userBehaviorDevice);
        return response;
    }

    /**
     * 保存行为信息--数美
     * @param userBehaviorDeviceShumei
     * @return
     */
    @Override
    public Response<Boolean> saveUserBehaviorDeviceShumei(UserBehaviorDeviceShumeiRO userBehaviorDeviceShumei) {
        if(null == userBehaviorDeviceShumei){
            LOGGER.info("UserBehaviorServiceFacade.saveUserBehaviorDeviceShumei param can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK,"参数不能为空");
        }
        if(null == userBehaviorDeviceShumei.getUserCode()){
            LOGGER.info("UserBehaviorServiceFacade.saveUserBehaviorDeviceShumei param userCode can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK,"参数不能为空");
        }
        Response<Boolean> response = userBehaviorApplication.saveUserBehaviorDeviceShumei(userBehaviorDeviceShumei);
        return response;
    }

    /**
     * 保存行为信息--gps
     * @param userBehaviorGps
     * @return
     */
    @Override
    public Response<Boolean> saveUserBehaviorGps(UserBehaviorGpsRO userBehaviorGps) {
        if(null == userBehaviorGps){
            LOGGER.info("UserBehaviorServiceFacade.saveUserBehaviorGps param can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK,"参数不能为空");
        }
        if(null == userBehaviorGps.getUserCode()){
            LOGGER.info("UserBehaviorServiceFacade.saveUserBehaviorGps param userCode can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK,"参数不能为空");
        }
        Response<Boolean> response = userBehaviorApplication.saveUserBehaviorGps(userBehaviorGps);
        return response;
    }

    /**
     * 保存行为信息--wifi
     * @param userBehaviorWifi
     * @return
     */
    @Override
    public Response<Boolean> saveUserBehaviorWifi(UserBehaviorWifiRO userBehaviorWifi) {
        if(null == userBehaviorWifi){
            LOGGER.info("UserBehaviorServiceFacade.saveUserBehaviorWifi param can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK,"参数不能为空");
        }
        if(null == userBehaviorWifi.getUserCode()){
            LOGGER.info("UserBehaviorServiceFacade.saveUserBehaviorWifi param userCode can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK,"参数不能为空");
        }
        Response<Boolean> response = userBehaviorApplication.saveUserBehaviorWifi(userBehaviorWifi);
        return response;
    }
}
